package com.test.listener.noannotation;

import com.test.listener.event_listener.TestNoAnnotationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyNoAnnotationListener implements ApplicationListener<TestNoAnnotationEvent> {

    /**
     * 不用注解的监听器，需要实现ApplicationListener接口，并重写onApplicationEvent方法，入参是需要监听的事件类
     */
    @Override
    public void onApplicationEvent(TestNoAnnotationEvent event) {     // 监听的是TestNoAnnotationEvent这个类
        System.out.println("2--非注解监听器：===========" + event.getMsg());
    }

}